/*
 * Copyright 2008-2012 Centro Andaluz de Innovación y Tecnologías de la
 * Información y las Comunicaciones (CITIC). All Rights Reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
 *
 * Please contact CITIC - Edificio CITIC, C/ Marie Curie, 6 Parque
 * Tecnológico de Andalucía 29590 - Campanillas, Málaga, Spain
 * or visit www.citic.es, if you need additional information or
 * have any questions.
 */
package es.citic.puedes.youtube;

/**
 * 
 * class that represents a preference from a user
 * 
 * 
 */
public class Preference implements Comparable<Preference> {

	/**
	 * preference keyword
	 */
	private String name;

	/**
	 * preference value. The preference will be ordered using this value
	 */
	private Float value;

	/**
	 * constructor with parameters
	 * 
	 * @param name
	 *            preference keyword
	 * @param value
	 *            preference value
	 */
	public Preference(String name, Float value) {
		this.name = name;
		this.value = value;
	}

	/**
	 * @return the preference name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @return the preference value
	 */
	public Float getValue() {
		return value;
	}

	@Override
	public int compareTo(Preference pref) {
		int comparison = 0;

		// object greater than pref..
		if ((value.compareTo(pref.value) > 0)) {
			comparison = 1;

			// object smaller than pref..
		} else if ((value.compareTo(pref.value) < 0)) {
			comparison = -1;

			// the same value but distinct keyword
		} else if ((value.compareTo(pref.value) == 0)
				&& (name.compareTo(pref.getName()) != 0)) {

			comparison = 1;

		}

		return comparison;
	}

}
